from page.BasePage import BasePage
from selenium.webdriver.common.by import By

class MainPage(BasePage):
    # 类属性
    # 页面元素的定位方式都已类属性的方式定义出来
    iCloseRegister = (By.XPATH, "//i[text()='close']") #关闭注册对话框的i标签
    iTranslate = (By.XPATH, "//i[text()='translate']")
    divChinese = (By.XPATH, "//div[text()='中文简体']")

    inputRegisterName = (By.CSS_SELECTOR, ".q-card>div:nth-of-type(2)>label:nth-of-type(1) input")
    inputRegisterPassword1 = (By.CSS_SELECTOR, ".q-card>div:nth-of-type(2)>label:nth-of-type(2) input")
    inputRegisterPassword2 = (By.CSS_SELECTOR, ".q-card>div:nth-of-type(2)>label:nth-of-type(3) input")

    divRegisterSubmit = (By.XPATH, "//div[@class='q-card']//span[text()='注册']")

    divNotification = (By.CSS_SELECTOR, "div.q-notification__message")

    divLanguageList = (By.CSS_SELECTOR, "body>div:last-child .q-list>div")

    # 操作层 对某一个控件操作的特殊场景
    def get_notification_message(self):
        return self.get_text(self.divNotification, until_not_null=True)

    # 3.业务层
    def select_language_by_index(self, i):
        self.click(self.iTranslate)
        elements = self.find_elements(self.divLanguageList)
        self.click_element(elements[i])
    # 注册
    def register(self):
        pass

    # 登录
    def login(self):
        pass

